package store.impl;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class FileParsUtil {

    public static String getValue(File file, String key) {
        try {

            final FileReader fileReader = new FileReader(file);
            final BufferedReader bufferedFileReader = new BufferedReader(fileReader);
            String line = bufferedFileReader.readLine();
            while (line != null) {
                String UTF8Str = new String(line.getBytes(), "UTF-8");
                final String[] split = UTF8Str.split("=");
                if (split[0].equals(key)) {
                    return split[1];
                }
                line = bufferedFileReader.readLine();
            }
        } catch (IOException e) {
            System.out.println("error during reading file" + file.getAbsolutePath() + " prop " + key);
        }
        return "";
    }
}
